<?php
namespace App\Models;

class SendSocketToGame {

    public static function CreateSocket()
    {
        $conf = \Config::get("services.platform_service");
        $ip = $conf["ip"];
        //$ip = '192.168.3.66';
        $port = $conf["port"];

        $socket = new \App\Third\Game\SocketClient($ip, $port);
        return $socket;
    }

    public static function CloseSocket($socket)
    {
        $defaultSock = null;
        $socket->close($defaultSock);
    }

    public static function SendAction($func)
    {
        $socket = self::CreateSocket();
        $ret = call_user_func($func, $socket);
        self::CloseSocket($socket);

        return $ret;
    }
}